<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <title>示例信息查询</title>
  <style type="text/css">
    table {
      border-collapse: collapse;
      border: 1px black solid;
    }
    form {
      display: inline;
    }
    td {
      border: 1px solid;
      text-align: center;
    }
  </style>
</head>
<body>
<div align="center">
  <form method="post" action="${pageContext.request.contextPath}/system/add">
    <input type="text" name="field2" placeholder="名称">
    <button onclick="this.parentNode.submit()">添加</button>
  </form>
  <form method="post" action="${pageContext.request.contextPath}/system">
    <input type="text" name="kw"
      <c:if test="${kw!=null&&sessionScope['kw']!=''}">
        <c:out value="value='${sessionScope.kw}'" escapeXml="" />
      </c:if>
      placeholder="关键词">
    <input type="submit" value="查询">
  </form>
  <c:if test="${requestScope.entities.size()>0}">
    <table style="border: 1px black solid;">
      <tr>
        <th width="50">字段1</th>
        <th>字段2</th>
        <th>操作</th>
      </tr>
      <c:forEach items="${requestScope.entities}" var="obj">
        <tr>
          <td>${obj.field1}</td>
          <td>
            <form id="${obj.field1}" action="${pageContext.request.contextPath}/system/modify" method="post">
              <input type="hidden" name="field1" value="${obj.field1}" readonly>
              <input type="text" name="field2" value="${obj.field2}" placeholder="field2">
            </form>
          </td>
          <td>
            <button onclick="document.getElementById('${obj.field1}').submit()">修改</button>
          </td>
          <td>
            <form action="${pageContext.request.contextPath}/system/remove" method="post">
              <input type="hidden" name="field1" value="${obj.field1}" readonly>
              <button>删除</button>
            </form>
          </td>
        </tr>
      </c:forEach>
    </table>
  </c:if>
</div>
</body>
</html>
